package ${basePackage}.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.unswift.annotation.api.Api;
import com.unswift.annotation.api.ApiField;
import com.unswift.annotation.api.ApiMethod;
import ${basePackage}.annotation.request.Auth;
<#if stringUtils.contains(dataOperator,'create',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}CreateBo;
</#if>
<#if stringUtils.contains(dataOperator,'delete',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}DeleteBo;
</#if>
<#if stringUtils.contains(dataOperator,'export',',') && exportSame>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ExportBo;
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ExportStopBo;
</#if>
<#if stringUtils.contains(dataOperator,'import',',') && exportSame>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ImportBo;
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ImportStopBo;
</#if>
<#if stringUtils.contains(dataOperator,'list',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}PageBo;
</#if>
<#if stringUtils.contains(dataOperator,'update',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}UpdateBo;
</#if>
<#if stringUtils.contains(dataOperator,'view',',')>
import ${basePackage}.pojo.bo.${module}.${currModule}.${entityName}ViewBo;
</#if>
<#if stringUtils.contains(dataOperator,'create',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}CreateDto;
</#if>
<#if stringUtils.contains(dataOperator,'delete',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}DeleteDto;
</#if>
<#if stringUtils.contains(dataOperator,'export',',') && exportSame>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ExportDto;
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ExportStopDto;
</#if>
<#if stringUtils.contains(dataOperator,'import',',') && exportSame>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ImportDto;
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ImportStopDto;
</#if>
<#if stringUtils.contains(dataOperator,'list',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}PageDto;
</#if>
<#if stringUtils.contains(dataOperator,'update',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}UpdateDto;
</#if>
import ${basePackage}.pojo.vo.ResponseBody;
<#if stringUtils.contains(dataOperator,'view',',')>
import ${basePackage}.pojo.dto.${module}.${currModule}.${entityName}ViewDto;
</#if>
<#if stringUtils.contains(dataOperator,'create',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}CreateVo;
</#if>
<#if stringUtils.contains(dataOperator,'delete',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}DeleteVo;
</#if>
<#if stringUtils.contains(dataOperator,'export',',') && exportSame>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ExportVo;
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ExportStopVo;
</#if>
<#if stringUtils.contains(dataOperator,'import',',') && exportSame>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ImportVo;
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ImportStopVo;
</#if>
<#if stringUtils.contains(dataOperator,'list',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}PageVo;
</#if>
<#if stringUtils.contains(dataOperator,'update',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}UpdateVo;
</#if>
<#if stringUtils.contains(dataOperator,'view',',')>
import ${basePackage}.pojo.vo.${module}.${currModule}.${entityName}ViewVo;
</#if>
<#if stringUtils.contains(dataOperator,'list',',')>
import ${basePackage}.pojo.vo.page.PageVo;
</#if>
import ${basePackage}.service.${entityName}Service;

@RestController
@RequestMapping("/${entitySampleName}")
@Api(value="${tableComment}对外接口", author="${username}", date="${date}", version="1.0.0")
public class ${entityName}Controller extends BaseController{
	
	@Autowired
	@ApiField("${tableComment}服务")
	private ${entityName}Service ${entitySampleName}Service;
	<#if stringUtils.contains(dataOperator,'list',',')>
	
	@Auth("${module}.${currModule}.pageList")
	@RequestMapping(value="/findPageList", method=RequestMethod.POST)
	@ApiMethod(value="${tableComment}分页列表", params=@ApiField("查询条件"), returns=@ApiField("匹配查询条件的分页数据"))
	public ResponseBody<PageVo<${entityName}PageVo>> findPageList(@RequestBody ${entityName}PageDto searchDto){
		${entityName}PageBo searchBo=this.convertPojo(searchDto, ${entityName}PageBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.findPageList(searchBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'view',',')>
	
	@Auth("${module}.${currModule}.view")
	@RequestMapping(value="/view", method=RequestMethod.POST)
	@ApiMethod(value="${tableComment}详情", params=@ApiField("详情Dto对象，包含主键"), returns=@ApiField("详情数据"))
	public ResponseBody<${entityName}ViewVo> view(@RequestBody ${entityName}ViewDto viewDto){
		${entityName}ViewBo viewBo=this.convertPojo(viewDto, ${entityName}ViewBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.view(viewBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'create',',')>
	
	@Auth("${module}.${currModule}.create")
	@RequestMapping(value="/create", method=RequestMethod.POST)
	@ApiMethod(value="创建${tableComment}", params=@ApiField("创建的数据对象"), returns=@ApiField("创建结果Vo->result:{0：未创建，1：已创建}"))
	public ResponseBody<${entityName}CreateVo> create(@RequestBody ${entityName}CreateDto createDto){
		${entityName}CreateBo createBo=this.convertPojo(createDto, ${entityName}CreateBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.create(createBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'update',',')>
	
	@Auth("${module}.${currModule}.update")
	@RequestMapping(value="/update", method=RequestMethod.POST)
	@ApiMethod(value="更新${tableComment}", params=@ApiField("更新的数据对象"), returns=@ApiField("更新结果Vo->result:{0：未更新，1：已更新}"))
	public ResponseBody<${entityName}UpdateVo> update(@RequestBody ${entityName}UpdateDto updateDto){
		${entityName}UpdateBo updateBo=this.convertPojo(updateDto, ${entityName}UpdateBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.update(updateBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'delete',',')>
	
	@Auth("${module}.${currModule}.delete")
	@RequestMapping(value="/delete", method=RequestMethod.POST)
	@ApiMethod(value="删除${tableComment}", params=@ApiField("删除Dto对象，包含主键"), returns=@ApiField("删除结果Vo->result:{0：未删除，1：已删除}"))
	public ResponseBody<${entityName}DeleteVo> delete(@RequestBody ${entityName}DeleteDto deleteDto){
		${entityName}DeleteBo deleteBo=this.convertPojo(deleteDto, ${entityName}DeleteBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.delete(deleteBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'export',',') && exportSame>
	
	@Auth("${module}.${currModule}.export")
	@RequestMapping(value="/export", method=RequestMethod.POST)
	@ApiMethod(value="导出${tableComment}", params=@ApiField("导出Dto对象"), returns=@ApiField("导出结果Vo->id:任务id,result:{0：未创建，1：已创建}"))
	public ResponseBody<${entityName}ExportVo> export(@RequestBody ${entityName}ExportDto exportDto){
		${entityName}ExportBo exportBo=this.convertPojo(exportDto, ${entityName}ExportBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.export(exportBo));
	}
	
	@Auth("${module}.${currModule}.export")
	@RequestMapping(value="/export/stop", method=RequestMethod.POST)
	@ApiMethod(value="停止导出${tableComment}", params=@ApiField("停止对象"), returns=@ApiField("停止结果Vo->result:{0：未停止，1：已停止}"))
	public ResponseBody<${entityName}ExportStopVo> exportStop(@RequestBody ${entityName}ExportStopDto exportStopDto){
		${entityName}ExportStopBo exportStopBo=this.convertPojo(exportStopDto, ${entityName}ExportStopBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.stop(exportStopBo));
	}
	</#if>
	<#if stringUtils.contains(dataOperator,'import',',') && exportSame>
	
	@Auth("${module}.${currModule}.import")
	@RequestMapping(value="/import", method=RequestMethod.POST)
	@ApiMethod(value="导入${tableComment}", params=@ApiField("导出Dto对象"), returns=@ApiField("导入结果Vo->id:任务id,result:{0：未创建，1：已创建}"))
	public ResponseBody<${entityName}ImportVo> imports(@RequestBody ${entityName}ImportDto importDto){
		${entityName}ImportBo importBo=this.convertPojo(importDto, ${entityName}ImportBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.imports(importBo));
	}
	
	@Auth("${module}.${currModule}.import")
	@RequestMapping(value="/import/stop", method=RequestMethod.POST)
	@ApiMethod(value="停止导入${tableComment}", params=@ApiField("停止对象"), returns=@ApiField("停止结果Vo->result:{0：未停止，1：已停止}"))
	public ResponseBody<${entityName}ImportStopVo> importStop(@RequestBody ${entityName}ImportStopDto importStopDto){
		${entityName}ImportStopBo importStopBo=this.convertPojo(importStopDto, ${entityName}ImportStopBo.class);//将Dto转换为Bo
		return ResponseBody.success(${entitySampleName}Service.stop(importStopBo));
	}
	</#if>
}